package com.damai.pay;

import java.util.HashMap;
import java.util.Map;

import org.apache.http.util.TextUtils;

import com.citywithincity.utils.ConfigReader;
import com.damai.utils.LogUtil;

public class PayAdapterManager {
	
	private static Map<String, PayAdapter<?>> map = new HashMap<String, PayAdapter<?>>();
	
	
	public static String PREFIX = "";
	static{
		String serverUrl =  ConfigReader.getDefault().get("server_url");
		if(TextUtils.isEmpty(serverUrl)){
			LogUtil.log("server_url must be defined in config.xml!");
		}
		PREFIX = serverUrl+ "/payNotify/";
	}
	
	public static void register(String key,PayAdapter<?> adapter){
		map.put(key, adapter);
	}
	
	
	public static PayAdapter<?> getAdapter(String key){
		return map.get(key);
	}


	public static String getNotifyUrl(String key) {
		return PREFIX + key;
	}
}
